<template>
  <div>
    <div>
      <el-row>
        <el-col :xs="24" :sm="10" :md="10" :lg="10" :xl="10">
          <div class="detail_info">
            <div style="margin: 25px 20px 0px 25px">
              <img :src="info.zxlogo" alt="" style="
                  width: 58px;
                  height: 58px;
                  border-radius: 8px;
                " />
            </div>
            <div style="margin-top: 16px;">
              <span class="detail_title">{{ info.nickname }}</span>
              <div class="detail_text">
                <span>{{ info.mini_version }}</span>
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="24" :sm="14" :md="14" :lg="14" :xl="14">
          <div class="but_count">
            <el-button type="button" class="preview" @click="gotodown()">预览</el-button>
            <el-button type="button" class="upnew" @click="gotoUploadNew()">上传新版本</el-button>
          </div>
        </el-col>
      </el-row>
      <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
        style="margin-left: 15px ;margin-right: 15px;margin-top: 30px;" active-text-color="#fff">
        <el-row>
          <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8" v-for="(item,i) in navList" :key="i">
            <el-menu-item :index="item.name">{{ item.navItem }}</el-menu-item>
          </el-col>
        </el-row>
      </el-menu>
      <!-- 基本设置 -->
      <div v-if="actives == '/basicSet'">
        <form style="margin-top: 43px; padding-left: 15px;padding-right: 15px;">
          <div class="form-group col-sm-8">
            <label for="">应用名称</label>
            <input type="text" class="form-control" v-model="info.nickname">
          </div>
          <div class="col-sm-8">
            <label for="basic-url">短链接：</label>
            <div class="input-group">
              <span class="input-group-addon" id="basic-addon3">shorturl_domain</span>
              <input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3"
                v-model="info.shorturl">
            </div>
          </div>
          <div class="col-sm-8">
            <el-button type="primary" @click="editBasicFrom()" class="save">保存</el-button>
          </div>

        </form>
      </div>
      <!-- 高级设置 -->
      <div v-if="actives==='/advancedSet'">
        <form style="margin-top: 43px; padding-left: 15px;padding-right: 15px;">
          <div class="form-group col-sm-8">
            <label for="exampleInputEmail1">下载方式:</label>
            <el-radio-group v-model="info.share_method" @change="shareMethod">
              <el-radio :label="1">公开安装</el-radio>
              <el-radio :label="2">密码安装(输入密码)</el-radio>
              <!-- <el-radio :label="3">授权码安装</el-radio> -->
              <!-- <el-radio :label="3">付费安装(单价：1元/台)</el-radio> -->
            </el-radio-group>
            <input type="text" class="form-control" placeholder="请输入密码之后进行安装" v-if="info.share_method==2"
              v-model="info.downPwd">
            <input type="text" class="form-control" placeholder="请输入你需要安装的台数" v-if="info.share_method==3"
              v-model="info.downPwd">
          </div>

          <div class="form-group col-sm-8">
            <label for="">下载限制：</label>
            <input type="text" class="form-control" placeholder="请输入限制下载次数，不填或0表示不限制" v-model="info.xzdownum">
          </div>
          <div class="form-group col-sm-8">
            <label for="">备注：</label>
            <input type="text" class="form-control" placeholder="请输入备注说明" v-model="info.beizhu">
          </div>
          <div class="form-group col-sm-8">
            <label for="">应用介绍：</label>
            <textarea class="form-control" rows="3" v-model="info.beifen"></textarea>
          </div>
          <div class="col-sm-8">
            <el-button type="primary" @click="editAdvancedFrom()" class="save">保存</el-button>
          </div>
        </form>
      </div>
      <!-- 模板设置 -->
      <div v-if="actives==='/templateSet'">
        <form style="margin-top: 43px; padding-left: 15px;padding-right: 15px;">
          <div class="form-group">
            <label for="exampleInputEmail1">语言设置:</label>
            <el-radio-group v-model="info.moban_language" @change="languageChange">
              <el-radio :label="1">简体中文</el-radio>
              <el-radio :label="2">English</el-radio>
              <el-radio :label="3">繁体中文</el-radio>
            </el-radio-group>
          </div>
          <el-row>
            <el-radio-group class="moban_language_box" v-model="info.mobanid" @change="mobanIDChange">
              <el-col :xs="12" :sm="12" :md="6" :lg="6" :xl="6" v-for="(item, index) in mobanList" :key="index">
                <div class="demo-image__preview">
                  <el-image style="
                      width: 100%;
                      height: 80%;
                      object-fit: cover;
                      border-radius: 4px;
                      box-shadow: 0px 4px 6px 4px rgba(0, 0, 0, 0.06);
                    " :src="item.url">
                  </el-image>
                  <el-radio :label="item.id">{{item.title}}</el-radio>
                </div>
              </el-col>
            </el-radio-group>
          </el-row>
          <el-button type="primary" @click="submitMobanForm()" class="save">保存</el-button>
        </form>
      </div>
    </div>

  </div>
</template>

<script>
  import filters from "../../../utils/filters";
  export default {
    filters: filters,
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
      //这里存放数据
      return {
        appUrl: "../../../static/App图标.png",
        info: [], //数据信息
        labelPosition: "left",
        activeName: "first",
        isChecked: '',
        radio1: 1,
        radio2: 5,
        mobanList: [],
        // 记录当前tab页
        actives: '/basicSet',
        activeIndex: '/basicSet', //绑定高亮
        navList: [{
            name: '/basicSet',
            navItem: '基本设置'
          },
          {
            name: '/advancedSet',
            navItem: '高级设置'
          },
          {
            name: '/templateSet',
            navItem: '模板设置'
          },

        ],
        ruleForm: {
          name: "",
          link: "",
        },

        imgObject: [{
            url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
            srcList: [
              "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
              "https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg",
            ],
          },
          {
            url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
            srcList: [
              "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg",
              "https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg",
            ],
          },

        ],
      };
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {
      appID(val) {
        this.appID = val;
        this.getList();
      },
    },
    //方法集合
    methods: {
      getList() {
        var params = new URLSearchParams();
        params.append("appid", this.$route.query.appID);
        this.$post(this.API.Supersignature_detail, params).then((res) => {
          let data = res.data;
          this.info = data.info;
        });
      },
      editBasicFrom() {
        var params = new URLSearchParams();
        params.append("appid", this.$route.query.appID);
        params.append("nickname", this.info.nickname);
        params.append("shorturl", this.info.shorturl);
        this.$post(this.API.Application_settingData, params).then((res) => {
          this.nickname = params.nickname;
          this.shorturl = params.shorturl;
          if (res.code == 1) {
            this.$message.success("修改成功");
            this.getList();
          } else {
            this.$message.success("修改失败");
          }
        });
      },
      editAdvancedFrom() {
        var params = new URLSearchParams();
        params.append("appid", this.$route.query.appID);
        params.append("share_method", this.info.share_method);
        params.append("beizhu", this.info.beizhu);
        params.append("beifen", this.info.beifen);
        params.append("downPwd", this.info.downPwd);
        this.$post(this.API.Application_settingData, params).then((res) => {
          this.share_method = params.share_method;
          this.beizhu = params.beizhu;
          this.beifen = params.beifen;
          if (res.code == 1) {
            this.$message.success("修改成功");
            this.getList();
          } else {
            this.$message.success("修改失败");
          }
        });
      },
      handleSelect(key, keyPath) {
        this.actives = key;
        this.activeIndex = key;
      },
      goUrl(path, name) {
        sessionStorage.setItem("currentTab", "first");
        this.$router.push({
          path: path,
          name: name,
        });
      },
      //修改模板信息
      submitMobanForm() {
        var params = new URLSearchParams();
        params.append("appid", this.$route.query.appID);
        params.append("mobanid", this.info.mobanid);
        params.append("moban_language", this.info.moban_language);
        this.$post(this.API.Application_settingData, params).then((res) => {
          console.log(res, "000");
          if (res.code == 1) {
            this.$message.success("修改成功");
            this.getList();
          } else {
            this.$message.error("修改失败");
          }
        });
      },
      //显示语言改变事件
      languageChange(e) {
        this.info.moban_language = e;
      },
      //模板改变
      mobanIDChange(e) {
        this.info.mobanid = e;
      },
      handleClick(tab, event) {
        // console.log(tab, event);
      },
      //上传新版本
      gotoUploadNew() {
        let appID = this.$route.query.appID;
        this.$router.push({
          path: "signatureSuper",
          name: "signatureSuper",
          query: {
            appID: appID,
          },
        });

        window.scrollTo(0, 0);
        sessionStorage.setItem("currentTab_title", "signatureSuper"); //设置顶部菜单选中项
        sessionStorage.setItem("setMenuIndex", 0); //设置我的应用左侧菜单选中项
        location.reload();
      },
      //预览
      // showDownPage() {
      //   let down_url = this.info.down_url;
      //   window.open(down_url, '_blank');
      // },
      gotodown() {
        var temp = window.open('_blank')
        temp.location.href = "https://down.lmffw.com/" + encodeURIComponent(this.info.shorturl);
      },
      //下载方式改变事件
      shareMethod(e) {
        this.info.share_method = e;
        this.isChecked = e;
      },
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created() {
      this.getList();
      this.shareMethod();

    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {

    },
  };

</script>
<style scoped>
  label {
    /* margin-bottom: 0px !important; */
    color: #fff;
  }

  div>>>.save {
    width: 160px;
    height: 36px;
    background: #ff7226;
    border-radius: 4px;
    padding: 0px;
    margin-top: 30px;
    margin-bottom: 30px;
    border: 0px;
  }

  div>>>.el-input {
    width: 500px;
  }

  div>>>.el-textarea__inner {
    width: 500px;
  }

  div>>>.el-form-item {
    margin-top: 27px;
  }

  .previewClick {
    width: 140px;
    height: 32px;
    background: #1d1d1d;
    border-radius: 0px 0px 4px 4px;
    opacity: 0.6;
    margin-top: -46px;
    z-index: 1;
    color: #fff;
    line-height: 32px;
    text-align: center;
  }

  div>>>.demo-image__preview {
    width: 140px;
    height: 300px;
    border-radius: 4px;
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
  }



  .block>>>.el-date-editor .el-range__icon {
    margin-left: -5px !important;
    line-height: 18px !important;
  }

  .orderHeader>>>.el-form-item__content {
    line-height: 40px !important;
  }


  div>>>.el-card {
    border: none;
  }

  div>>>.el-progress-bar {
    width: 200px;
  }

  /* 按钮 */
  .buy {
    background: -webkit-linear-gradient(-135deg, #ff9d68, #ff7226);
    background: -o-linear-gradient(-135deg, #ff9d68, #ff7226);
    background: -moz-linear-gradient(-135deg, #ff9d68, #ff7226);
    background: linear-gradient(-135deg, #ff9d68, #ff7226);
    color: #fff;
    font-size: 16px;
  }

  .cell span {
    width: 1px;
    /*根据自己项目进行定义宽度*/
    overflow: hidden;
    /*设置超出的部分进行影藏*/
    text-overflow: ellipsis;
    /*设置超出部分使用省略号*/
    white-space: nowrap;
    /*设置为单行*/
  }

  .box1 {
    width: 100px;
    height: 50px;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    /* border-right: 1px solid #E0E0E0; */
  }

  .box1:first-child {
    border-right: 1px solid #e0e0e0;
  }

  .box2 {
    margin: 0px 20px;
  }

  .detail_info {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .detail_title {
    width: 36px;
    height: 18px;
    font-size: 18px;
    font-family: PingFang-SC-Medium, PingFang-SC;
    font-weight: 500;
    color: #fff;
  }

  .detail_text {
    height: 12px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999;
    margin-top: 5px;
  }

  .detail_text span:first-child {
    margin-left: 0px;
  }

  .detail_text span {
    margin-left: 22px;
  }

  .table>thead>tr>th {
    padding: 8px 0px 30px 30px !important;
    border: none;
  }

  div>>>.preview,
  .merge {
    border: 2px solid #ff7226;
    color: #ff7226;
  }

  .preview:hover {
    background-color: #ff7226;
    color: #fff;
  }

  .upnew:hover {
    border: 2px solid #ff7226;
    background-color: #fff;
    color: #ff7226;
  }

  .upnew {
    border: 2px solid #ff7226;
    background-color: #ff7226;
    color: #fff;
  }

  div>>>.el-tabs--border-card>.el-tabs__header {
    background-color: transparent;
    border: 1px solid #ff7226;
    width: 899px;
  }

  div>>>.el-tabs--border-card {
    border: none;
    box-shadow: none;
    background: transparent;
  }

  div>>>.el-tabs__nav-wrap {
    height: 50px;
  }

  div>>>.el-tabs__item {
    height: 50px;
    line-height: 50px;
  }

  div>>>.el-tabs__item {
    padding: 0px 121px;
  }

  div>>>.el-tabs--top.el-tabs--border-card>.el-tabs__header .el-tabs__item:nth-child(2) {
    padding-left: 121px;
  }

  div>>>.el-tabs--top.el-tabs--border-card>.el-tabs__header .el-tabs__item:last-child {
    padding-right: 121px;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item.is-active {
    color: #fff;
    background-color: #ff7226;
    border-right-color: #ff7226;
    border-left-color: #ff7226;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item.is-active:hover {
    color: #fff;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item {
    color: #ff7226;
  }

  div>>>.el-tabs--border-card>.el-tabs__header .el-tabs__item:hover {
    color: #ff7226;
  }

  .demo-ruleForm {
    margin-left: -10px;
  }

  div>>>.el-radio__input.is-checked .el-radio__inner {
    border-color: #ff720b;
    background: #ff720b;
  }

  div>>>.el-radio__input.is-checked+.el-radio__label {
    color: #ff720b;
  }

  div>>>.moban_language_box {
    display: flex;
    flex-wrap: wrap;
  }

  .but_count {
    display: flex;
    justify-content: flex-end;
    margin-right: 20px;
    margin-top: 30px;
  }

  div>>>.el-menu-item {
    text-align: center;
    background-color: none;
    color: #ff7226;
  }

  div>>>.el-menu-item:hover {
    background-color: #ff7226;

  }

  div>>>.el-menu-item:not(.is-disabled):hover {
    color: #fff;
  }

  div>>>.is-active {
    background-color: #ff7226;
  }

  div>>>.el-menu.el-menu--horizontal {
    background-color: #272727;
    border-bottom: 0px;
  }

  .form-control {
    background-color: #272727;
    border-radius: 0px;
    border: 0px;
    color: #999;
  }

  .form-control:focus {
    border-color: none;
  }

  #basic-addon3 {
    background-color: #3d3d3d;
    border-radius: 0px;
    border: 0px;
    color: #999;
  }

  /* 媒体查询 */
  @media (max-width: 992px) {}

  @media (max-width: 768px) {
    .but_count {
      display: flex;
      justify-content: flex-start;
      margin-left: 20px;
      margin-bottom: -20px;
    }
  }

  @media (max-width: 576px) {
    .but_count {
      display: flex;
      justify-content: flex-start;
      margin-left: 28px;
      margin-bottom: -20px;
    }
  }

  @media (max-width: 414px) {
    .but_count {
      display: flex;
      justify-content: center;
      margin-bottom: -20px;
      margin-left: -140px;
    }

    .el-button {
      padding: 8px 15px;
    }


  }

  @media (max-width: 375px) {
    .but_count {

      margin-bottom: -20px;
      margin-left: -100px;
    }

    .el-button {
      padding: 8px 15px;
    }

  }

</style>
